#pragma once

namespace TradeIt {

	using namespace System;
	using namespace System::ComponentModel;
	using namespace System::Collections;
	using namespace System::Windows::Forms;
	using namespace System::Data;
	using namespace System::Drawing;

	/// <summary>
	/// Summary for frmTrader
	/// </summary>
	public ref class frmTrader : public System::Windows::Forms::Form
	{
	public:
		frmTrader(void)
		{
			InitializeComponent();
			//
			//TODO: Add the constructor code here
			//
		}

	protected:
		/// <summary>
		/// Clean up any resources being used.
		/// </summary>
		~frmTrader()
		{
			if (components)
			{
				delete components;
			}
		}
	private: AxTWSLib::AxTws^  tws1;
	protected: 
	private: System::Windows::Forms::TabControl^  tabControl1;
	private: System::Windows::Forms::TabPage^  tb1;
	private: System::Windows::Forms::Button^  btnBuy_S1;
	private: System::Windows::Forms::Button^  btnSell_S1;
	private: System::Windows::Forms::Label^  label1;
	private: System::Windows::Forms::TextBox^  txtSymbol_S1;
	private: System::Windows::Forms::Label^  label2;
	private: System::Windows::Forms::TextBox^  txtTrigger_S1;
	private: System::Windows::Forms::Label^  label3;
	private: System::Windows::Forms::TextBox^  txtSize_S1;
	private: System::Windows::Forms::Label^  label10;
	private: System::Windows::Forms::TextBox^  txtStop_S1;
	private: System::Windows::Forms::TabPage^  tb2;
	private: System::Windows::Forms::Button^  btnBuy_S2;
	private: System::Windows::Forms::Button^  btnSell_S2;
	private: System::Windows::Forms::TextBox^  txtStopLoss_S2;
	private: System::Windows::Forms::TextBox^  txtLast_S2;
	private: System::Windows::Forms::TextBox^  txtSteps_S2;
	private: System::Windows::Forms::TextBox^  txtDelta_S2;
	private: System::Windows::Forms::Label^  label7;
	private: System::Windows::Forms::Label^  label8;
	private: System::Windows::Forms::Label^  label6;
	private: System::Windows::Forms::TextBox^  txtSymbol_S2;
	private: System::Windows::Forms::Label^  label5;
	private: System::Windows::Forms::MenuStrip^  menuStrip1;
	private: System::Windows::Forms::ToolStripMenuItem^  fileToolStripMenuItem;
	private: System::Windows::Forms::ToolStripMenuItem^  optionsToolStripMenuItem;
	private: System::Windows::Forms::ToolStripSeparator^  toolStripSeparator1;
	private: System::Windows::Forms::ToolStripMenuItem^  exitToolStripMenuItem;
	private: System::Windows::Forms::ToolStripMenuItem^  informationToolStripMenuItem;
	private: System::Windows::Forms::ToolStripMenuItem^  logToolStripMenuItem;
	private: System::Windows::Forms::ToolStripMenuItem^  triggerExplorerToolStripMenuItem;
	private: System::Windows::Forms::ToolStripMenuItem^  closeAllPositionsToolStripMenuItem;
	private: System::Windows::Forms::ToolStripMenuItem^  doItToolStripMenuItem;
	private: System::Windows::Forms::Label^  label4;


	private:
		/// <summary>
		/// Required designer variable.
		/// </summary>
		System::ComponentModel::Container ^components;

#pragma region Windows Form Designer generated code
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		void InitializeComponent(void)
		{
			System::ComponentModel::ComponentResourceManager^  resources = (gcnew System::ComponentModel::ComponentResourceManager(frmTrader::typeid));
			this->tws1 = (gcnew AxTWSLib::AxTws());
			this->tabControl1 = (gcnew System::Windows::Forms::TabControl());
			this->tb1 = (gcnew System::Windows::Forms::TabPage());
			this->btnBuy_S1 = (gcnew System::Windows::Forms::Button());
			this->btnSell_S1 = (gcnew System::Windows::Forms::Button());
			this->label1 = (gcnew System::Windows::Forms::Label());
			this->txtSymbol_S1 = (gcnew System::Windows::Forms::TextBox());
			this->label2 = (gcnew System::Windows::Forms::Label());
			this->txtTrigger_S1 = (gcnew System::Windows::Forms::TextBox());
			this->label3 = (gcnew System::Windows::Forms::Label());
			this->txtSize_S1 = (gcnew System::Windows::Forms::TextBox());
			this->label10 = (gcnew System::Windows::Forms::Label());
			this->txtStop_S1 = (gcnew System::Windows::Forms::TextBox());
			this->tb2 = (gcnew System::Windows::Forms::TabPage());
			this->btnBuy_S2 = (gcnew System::Windows::Forms::Button());
			this->btnSell_S2 = (gcnew System::Windows::Forms::Button());
			this->txtStopLoss_S2 = (gcnew System::Windows::Forms::TextBox());
			this->txtLast_S2 = (gcnew System::Windows::Forms::TextBox());
			this->txtSteps_S2 = (gcnew System::Windows::Forms::TextBox());
			this->txtDelta_S2 = (gcnew System::Windows::Forms::TextBox());
			this->label7 = (gcnew System::Windows::Forms::Label());
			this->label8 = (gcnew System::Windows::Forms::Label());
			this->label6 = (gcnew System::Windows::Forms::Label());
			this->txtSymbol_S2 = (gcnew System::Windows::Forms::TextBox());
			this->label5 = (gcnew System::Windows::Forms::Label());
			this->menuStrip1 = (gcnew System::Windows::Forms::MenuStrip());
			this->fileToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
			this->optionsToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
			this->toolStripSeparator1 = (gcnew System::Windows::Forms::ToolStripSeparator());
			this->exitToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
			this->informationToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
			this->logToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
			this->triggerExplorerToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
			this->closeAllPositionsToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
			this->doItToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
			this->label4 = (gcnew System::Windows::Forms::Label());
			(cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->tws1))->BeginInit();
			this->tabControl1->SuspendLayout();
			this->tb1->SuspendLayout();
			this->tb2->SuspendLayout();
			this->menuStrip1->SuspendLayout();
			this->SuspendLayout();
			// 
			// tws1
			// 
			this->tws1->Enabled = true;
			this->tws1->Location = System::Drawing::Point(317, 181);
			this->tws1->Name = L"tws1";
			this->tws1->OcxState = (cli::safe_cast<System::Windows::Forms::AxHost::State^  >(resources->GetObject(L"tws1.OcxState")));
			this->tws1->Size = System::Drawing::Size(136, 19);
			this->tws1->TabIndex = 0;
			this->tws1->errMsg += gcnew AxTWSLib::_DTwsEvents_errMsgEventHandler(this, &frmTrader::tws1_errMsg);
			// 
			// tabControl1
			// 
			this->tabControl1->Controls->Add(this->tb1);
			this->tabControl1->Controls->Add(this->tb2);
			this->tabControl1->Location = System::Drawing::Point(1, 27);
			this->tabControl1->Name = L"tabControl1";
			this->tabControl1->SelectedIndex = 0;
			this->tabControl1->Size = System::Drawing::Size(272, 103);
			this->tabControl1->TabIndex = 24;
			this->tabControl1->TabStop = false;
			// 
			// tb1
			// 
			this->tb1->BackColor = System::Drawing::SystemColors::Control;
			this->tb1->Controls->Add(this->btnBuy_S1);
			this->tb1->Controls->Add(this->btnSell_S1);
			this->tb1->Controls->Add(this->label1);
			this->tb1->Controls->Add(this->txtSymbol_S1);
			this->tb1->Controls->Add(this->label2);
			this->tb1->Controls->Add(this->txtTrigger_S1);
			this->tb1->Controls->Add(this->label3);
			this->tb1->Controls->Add(this->txtSize_S1);
			this->tb1->Controls->Add(this->label10);
			this->tb1->Controls->Add(this->txtStop_S1);
			this->tb1->Location = System::Drawing::Point(4, 22);
			this->tb1->Name = L"tb1";
			this->tb1->Padding = System::Windows::Forms::Padding(3);
			this->tb1->Size = System::Drawing::Size(264, 77);
			this->tb1->TabIndex = 0;
			this->tb1->Text = L"Momentum Breaker";
			// 
			// btnBuy_S1
			// 
			this->btnBuy_S1->BackColor = System::Drawing::Color::FromArgb(static_cast<System::Int32>(static_cast<System::Byte>(224)), static_cast<System::Int32>(static_cast<System::Byte>(224)), 
				static_cast<System::Int32>(static_cast<System::Byte>(224)));
			this->btnBuy_S1->Enabled = false;
			this->btnBuy_S1->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 9.75F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point, 
				static_cast<System::Byte>(177)));
			this->btnBuy_S1->ForeColor = System::Drawing::Color::Green;
			this->btnBuy_S1->Location = System::Drawing::Point(9, 47);
			this->btnBuy_S1->Name = L"btnBuy_S1";
			this->btnBuy_S1->Size = System::Drawing::Size(44, 24);
			this->btnBuy_S1->TabIndex = 17;
			this->btnBuy_S1->Text = L"Buy";
			this->btnBuy_S1->UseVisualStyleBackColor = false;
			this->btnBuy_S1->Click += gcnew System::EventHandler(this, &frmTrader::btnBuy_S1_Click);
			// 
			// btnSell_S1
			// 
			this->btnSell_S1->BackColor = System::Drawing::Color::FromArgb(static_cast<System::Int32>(static_cast<System::Byte>(224)), static_cast<System::Int32>(static_cast<System::Byte>(224)), 
				static_cast<System::Int32>(static_cast<System::Byte>(224)));
			this->btnSell_S1->Enabled = false;
			this->btnSell_S1->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 9.75F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point, 
				static_cast<System::Byte>(177)));
			this->btnSell_S1->ForeColor = System::Drawing::Color::Red;
			this->btnSell_S1->Location = System::Drawing::Point(61, 47);
			this->btnSell_S1->Name = L"btnSell_S1";
			this->btnSell_S1->Size = System::Drawing::Size(44, 24);
			this->btnSell_S1->TabIndex = 18;
			this->btnSell_S1->Text = L"Sell";
			this->btnSell_S1->UseVisualStyleBackColor = false;
			this->btnSell_S1->Click += gcnew System::EventHandler(this, &frmTrader::btnSell_S1_Click);
			// 
			// label1
			// 
			this->label1->AutoSize = true;
			this->label1->BackColor = System::Drawing::SystemColors::Control;
			this->label1->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 8.25F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point, 
				static_cast<System::Byte>(177)));
			this->label1->ForeColor = System::Drawing::Color::Black;
			this->label1->Location = System::Drawing::Point(9, 5);
			this->label1->Name = L"label1";
			this->label1->Size = System::Drawing::Size(51, 13);
			this->label1->TabIndex = 4;
			this->label1->Text = L"Symbol:";
			// 
			// txtSymbol_S1
			// 
			this->txtSymbol_S1->BackColor = System::Drawing::Color::White;
			this->txtSymbol_S1->Enabled = false;
			this->txtSymbol_S1->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 8.25F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point, 
				static_cast<System::Byte>(177)));
			this->txtSymbol_S1->Location = System::Drawing::Point(9, 21);
			this->txtSymbol_S1->Name = L"txtSymbol_S1";
			this->txtSymbol_S1->Size = System::Drawing::Size(44, 20);
			this->txtSymbol_S1->TabIndex = 1;
			// 
			// label2
			// 
			this->label2->AutoSize = true;
			this->label2->BackColor = System::Drawing::SystemColors::Control;
			this->label2->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 8.25F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point, 
				static_cast<System::Byte>(177)));
			this->label2->ForeColor = System::Drawing::Color::Black;
			this->label2->Location = System::Drawing::Point(58, 5);
			this->label2->Name = L"label2";
			this->label2->Size = System::Drawing::Size(51, 13);
			this->label2->TabIndex = 6;
			this->label2->Text = L"Trigger:";
			// 
			// txtTrigger_S1
			// 
			this->txtTrigger_S1->BackColor = System::Drawing::Color::White;
			this->txtTrigger_S1->Enabled = false;
			this->txtTrigger_S1->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 8.25F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point, 
				static_cast<System::Byte>(177)));
			this->txtTrigger_S1->Location = System::Drawing::Point(61, 21);
			this->txtTrigger_S1->Name = L"txtTrigger_S1";
			this->txtTrigger_S1->Size = System::Drawing::Size(44, 20);
			this->txtTrigger_S1->TabIndex = 2;
			// 
			// label3
			// 
			this->label3->AutoSize = true;
			this->label3->BackColor = System::Drawing::SystemColors::Control;
			this->label3->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 8.25F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point, 
				static_cast<System::Byte>(177)));
			this->label3->ForeColor = System::Drawing::Color::Black;
			this->label3->Location = System::Drawing::Point(113, 5);
			this->label3->Name = L"label3";
			this->label3->Size = System::Drawing::Size(37, 13);
			this->label3->TabIndex = 7;
			this->label3->Text = L"Stop:";
			// 
			// txtSize_S1
			// 
			this->txtSize_S1->BackColor = System::Drawing::Color::White;
			this->txtSize_S1->Enabled = false;
			this->txtSize_S1->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 8.25F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point, 
				static_cast<System::Byte>(177)));
			this->txtSize_S1->Location = System::Drawing::Point(156, 21);
			this->txtSize_S1->Name = L"txtSize_S1";
			this->txtSize_S1->Size = System::Drawing::Size(94, 20);
			this->txtSize_S1->TabIndex = 11;
			this->txtSize_S1->TabStop = false;
			// 
			// label10
			// 
			this->label10->AutoSize = true;
			this->label10->BackColor = System::Drawing::SystemColors::Control;
			this->label10->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 8.25F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point, 
				static_cast<System::Byte>(177)));
			this->label10->ForeColor = System::Drawing::Color::Black;
			this->label10->Location = System::Drawing::Point(156, 5);
			this->label10->Name = L"label10";
			this->label10->Size = System::Drawing::Size(35, 13);
			this->label10->TabIndex = 8;
			this->label10->Text = L"Size:";
			// 
			// txtStop_S1
			// 
			this->txtStop_S1->BackColor = System::Drawing::Color::White;
			this->txtStop_S1->Enabled = false;
			this->txtStop_S1->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 8.25F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point, 
				static_cast<System::Byte>(177)));
			this->txtStop_S1->Location = System::Drawing::Point(113, 21);
			this->txtStop_S1->Name = L"txtStop_S1";
			this->txtStop_S1->Size = System::Drawing::Size(37, 20);
			this->txtStop_S1->TabIndex = 3;
			// 
			// tb2
			// 
			this->tb2->BackColor = System::Drawing::SystemColors::Control;
			this->tb2->Controls->Add(this->btnBuy_S2);
			this->tb2->Controls->Add(this->btnSell_S2);
			this->tb2->Controls->Add(this->txtStopLoss_S2);
			this->tb2->Controls->Add(this->txtLast_S2);
			this->tb2->Controls->Add(this->txtSteps_S2);
			this->tb2->Controls->Add(this->txtDelta_S2);
			this->tb2->Controls->Add(this->label4);
			this->tb2->Controls->Add(this->label7);
			this->tb2->Controls->Add(this->label8);
			this->tb2->Controls->Add(this->label6);
			this->tb2->Controls->Add(this->txtSymbol_S2);
			this->tb2->Controls->Add(this->label5);
			this->tb2->Location = System::Drawing::Point(4, 22);
			this->tb2->Name = L"tb2";
			this->tb2->Padding = System::Windows::Forms::Padding(3);
			this->tb2->Size = System::Drawing::Size(264, 77);
			this->tb2->TabIndex = 1;
			this->tb2->Text = L"Momentum Wave";
			// 
			// btnBuy_S2
			// 
			this->btnBuy_S2->BackColor = System::Drawing::Color::FromArgb(static_cast<System::Int32>(static_cast<System::Byte>(224)), static_cast<System::Int32>(static_cast<System::Byte>(224)), 
				static_cast<System::Int32>(static_cast<System::Byte>(224)));
			this->btnBuy_S2->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 9.75F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point, 
				static_cast<System::Byte>(177)));
			this->btnBuy_S2->ForeColor = System::Drawing::Color::Green;
			this->btnBuy_S2->Location = System::Drawing::Point(9, 47);
			this->btnBuy_S2->Name = L"btnBuy_S2";
			this->btnBuy_S2->Size = System::Drawing::Size(44, 24);
			this->btnBuy_S2->TabIndex = 24;
			this->btnBuy_S2->Text = L"Buy";
			this->btnBuy_S2->UseVisualStyleBackColor = false;
			this->btnBuy_S2->Click += gcnew System::EventHandler(this, &frmTrader::btnBuy_S2_Click);
			// 
			// btnSell_S2
			// 
			this->btnSell_S2->BackColor = System::Drawing::Color::FromArgb(static_cast<System::Int32>(static_cast<System::Byte>(224)), static_cast<System::Int32>(static_cast<System::Byte>(224)), 
				static_cast<System::Int32>(static_cast<System::Byte>(224)));
			this->btnSell_S2->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 9.75F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point, 
				static_cast<System::Byte>(177)));
			this->btnSell_S2->ForeColor = System::Drawing::Color::Red;
			this->btnSell_S2->Location = System::Drawing::Point(57, 47);
			this->btnSell_S2->Name = L"btnSell_S2";
			this->btnSell_S2->Size = System::Drawing::Size(46, 24);
			this->btnSell_S2->TabIndex = 25;
			this->btnSell_S2->Text = L"Sell";
			this->btnSell_S2->UseVisualStyleBackColor = false;
			this->btnSell_S2->Click += gcnew System::EventHandler(this, &frmTrader::btnSell_S2_Click);
			// 
			// txtStopLoss_S2
			// 
			this->txtStopLoss_S2->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 8.25F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point, 
				static_cast<System::Byte>(177)));
			this->txtStopLoss_S2->Location = System::Drawing::Point(159, 21);
			this->txtStopLoss_S2->Name = L"txtStopLoss_S2";
			this->txtStopLoss_S2->Size = System::Drawing::Size(92, 20);
			this->txtStopLoss_S2->TabIndex = 2;
			this->txtStopLoss_S2->TabStop = false;
			// 
			// txtLast_S2
			// 
			this->txtLast_S2->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 8.25F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point, 
				static_cast<System::Byte>(177)));
			this->txtLast_S2->Location = System::Drawing::Point(207, 47);
			this->txtLast_S2->Name = L"txtLast_S2";
			this->txtLast_S2->Size = System::Drawing::Size(44, 20);
			this->txtLast_S2->TabIndex = 3;
			this->txtLast_S2->TabStop = false;
			this->txtLast_S2->TextChanged += gcnew System::EventHandler(this, &frmTrader::txtLast_S2_TextChanged);
			// 
			// txtSteps_S2
			// 
			this->txtSteps_S2->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 8.25F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point, 
				static_cast<System::Byte>(177)));
			this->txtSteps_S2->Location = System::Drawing::Point(109, 21);
			this->txtSteps_S2->Name = L"txtSteps_S2";
			this->txtSteps_S2->Size = System::Drawing::Size(44, 20);
			this->txtSteps_S2->TabIndex = 3;
			this->txtSteps_S2->TabStop = false;
			// 
			// txtDelta_S2
			// 
			this->txtDelta_S2->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 8.25F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point, 
				static_cast<System::Byte>(177)));
			this->txtDelta_S2->Location = System::Drawing::Point(59, 21);
			this->txtDelta_S2->Name = L"txtDelta_S2";
			this->txtDelta_S2->Size = System::Drawing::Size(44, 20);
			this->txtDelta_S2->TabIndex = 2;
			this->txtDelta_S2->KeyUp += gcnew System::Windows::Forms::KeyEventHandler(this, &frmTrader::txtDelta_S2_KeyUp);
			// 
			// label7
			// 
			this->label7->AutoSize = true;
			this->label7->BackColor = System::Drawing::SystemColors::Control;
			this->label7->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 8.25F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point, 
				static_cast<System::Byte>(177)));
			this->label7->ForeColor = System::Drawing::Color::Black;
			this->label7->Location = System::Drawing::Point(159, 5);
			this->label7->Name = L"label7";
			this->label7->Size = System::Drawing::Size(92, 13);
			this->label7->TabIndex = 5;
			this->label7->Text = L"Stoploss Price:";
			// 
			// label8
			// 
			this->label8->AutoSize = true;
			this->label8->BackColor = System::Drawing::SystemColors::Control;
			this->label8->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 8.25F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point, 
				static_cast<System::Byte>(177)));
			this->label8->ForeColor = System::Drawing::Color::Black;
			this->label8->Location = System::Drawing::Point(110, 5);
			this->label8->Name = L"label8";
			this->label8->Size = System::Drawing::Size(43, 13);
			this->label8->TabIndex = 5;
			this->label8->Text = L"Steps:";
			// 
			// label6
			// 
			this->label6->AutoSize = true;
			this->label6->BackColor = System::Drawing::SystemColors::Control;
			this->label6->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 8.25F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point, 
				static_cast<System::Byte>(177)));
			this->label6->ForeColor = System::Drawing::Color::Black;
			this->label6->Location = System::Drawing::Point(59, 5);
			this->label6->Name = L"label6";
			this->label6->Size = System::Drawing::Size(41, 13);
			this->label6->TabIndex = 5;
			this->label6->Text = L"Delta:";
			// 
			// txtSymbol_S2
			// 
			this->txtSymbol_S2->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 8.25F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point, 
				static_cast<System::Byte>(177)));
			this->txtSymbol_S2->Location = System::Drawing::Point(9, 21);
			this->txtSymbol_S2->Name = L"txtSymbol_S2";
			this->txtSymbol_S2->Size = System::Drawing::Size(44, 20);
			this->txtSymbol_S2->TabIndex = 1;
			this->txtSymbol_S2->TextChanged += gcnew System::EventHandler(this, &frmTrader::txtSymbol_S2_TextChanged);
			this->txtSymbol_S2->GotFocus += gcnew System::EventHandler(this, &frmTrader::txtSymbol_S2_GotFocus);
			this->txtSymbol_S2->LostFocus += gcnew System::EventHandler(this, &frmTrader::txtSymbol_S2_LostFocus);
			// 
			// label5
			// 
			this->label5->AutoSize = true;
			this->label5->BackColor = System::Drawing::SystemColors::Control;
			this->label5->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 8.25F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point, 
				static_cast<System::Byte>(177)));
			this->label5->ForeColor = System::Drawing::Color::Black;
			this->label5->Location = System::Drawing::Point(9, 5);
			this->label5->Name = L"label5";
			this->label5->Size = System::Drawing::Size(51, 13);
			this->label5->TabIndex = 5;
			this->label5->Text = L"Symbol:";
			// 
			// menuStrip1
			// 
			this->menuStrip1->BackColor = System::Drawing::Color::FromArgb(static_cast<System::Int32>(static_cast<System::Byte>(224)), static_cast<System::Int32>(static_cast<System::Byte>(224)), 
				static_cast<System::Int32>(static_cast<System::Byte>(224)));
			this->menuStrip1->Items->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^  >(3) {this->fileToolStripMenuItem, 
				this->informationToolStripMenuItem, this->closeAllPositionsToolStripMenuItem});
			this->menuStrip1->Location = System::Drawing::Point(0, 0);
			this->menuStrip1->Name = L"menuStrip1";
			this->menuStrip1->Size = System::Drawing::Size(273, 24);
			this->menuStrip1->TabIndex = 25;
			this->menuStrip1->Text = L"menuStrip1";
			// 
			// fileToolStripMenuItem
			// 
			this->fileToolStripMenuItem->DropDownItems->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^  >(3) {this->optionsToolStripMenuItem, 
				this->toolStripSeparator1, this->exitToolStripMenuItem});
			this->fileToolStripMenuItem->Name = L"fileToolStripMenuItem";
			this->fileToolStripMenuItem->Size = System::Drawing::Size(35, 20);
			this->fileToolStripMenuItem->Text = L"File";
			// 
			// optionsToolStripMenuItem
			// 
			this->optionsToolStripMenuItem->Enabled = false;
			this->optionsToolStripMenuItem->Name = L"optionsToolStripMenuItem";
			this->optionsToolStripMenuItem->Size = System::Drawing::Size(152, 22);
			this->optionsToolStripMenuItem->Text = L"Options";
			this->optionsToolStripMenuItem->Click += gcnew System::EventHandler(this, &frmTrader::optionsToolStripMenuItem_Click);
			// 
			// toolStripSeparator1
			// 
			this->toolStripSeparator1->Name = L"toolStripSeparator1";
			this->toolStripSeparator1->Size = System::Drawing::Size(149, 6);
			// 
			// exitToolStripMenuItem
			// 
			this->exitToolStripMenuItem->Name = L"exitToolStripMenuItem";
			this->exitToolStripMenuItem->Size = System::Drawing::Size(152, 22);
			this->exitToolStripMenuItem->Text = L"Exit";
			this->exitToolStripMenuItem->Click += gcnew System::EventHandler(this, &frmTrader::exitToolStripMenuItem_Click);
			// 
			// informationToolStripMenuItem
			// 
			this->informationToolStripMenuItem->DropDownItems->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^  >(2) {this->logToolStripMenuItem, 
				this->triggerExplorerToolStripMenuItem});
			this->informationToolStripMenuItem->Name = L"informationToolStripMenuItem";
			this->informationToolStripMenuItem->Size = System::Drawing::Size(75, 20);
			this->informationToolStripMenuItem->Text = L"Information";
			// 
			// logToolStripMenuItem
			// 
			this->logToolStripMenuItem->Name = L"logToolStripMenuItem";
			this->logToolStripMenuItem->Size = System::Drawing::Size(152, 22);
			this->logToolStripMenuItem->Text = L"Log";
			this->logToolStripMenuItem->Click += gcnew System::EventHandler(this, &frmTrader::logToolStripMenuItem_Click);
			// 
			// triggerExplorerToolStripMenuItem
			// 
			this->triggerExplorerToolStripMenuItem->Enabled = false;
			this->triggerExplorerToolStripMenuItem->Name = L"triggerExplorerToolStripMenuItem";
			this->triggerExplorerToolStripMenuItem->Size = System::Drawing::Size(152, 22);
			this->triggerExplorerToolStripMenuItem->Text = L"Trigger Explorer";
			this->triggerExplorerToolStripMenuItem->Click += gcnew System::EventHandler(this, &frmTrader::triggerExplorerToolStripMenuItem_Click);
			// 
			// closeAllPositionsToolStripMenuItem
			// 
			this->closeAllPositionsToolStripMenuItem->DropDownItems->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^  >(1) {this->doItToolStripMenuItem});
			this->closeAllPositionsToolStripMenuItem->Name = L"closeAllPositionsToolStripMenuItem";
			this->closeAllPositionsToolStripMenuItem->Size = System::Drawing::Size(104, 20);
			this->closeAllPositionsToolStripMenuItem->Text = L"Close All Positions";
			// 
			// doItToolStripMenuItem
			// 
			this->doItToolStripMenuItem->Name = L"doItToolStripMenuItem";
			this->doItToolStripMenuItem->Size = System::Drawing::Size(152, 22);
			this->doItToolStripMenuItem->Text = L"Do It!";
			this->doItToolStripMenuItem->Click += gcnew System::EventHandler(this, &frmTrader::doItToolStripMenuItem_Click);
			// 
			// label4
			// 
			this->label4->AutoSize = true;
			this->label4->BackColor = System::Drawing::SystemColors::Control;
			this->label4->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 8.25F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point, 
				static_cast<System::Byte>(177)));
			this->label4->ForeColor = System::Drawing::Color::Black;
			this->label4->Location = System::Drawing::Point(117, 50);
			this->label4->Name = L"label4";
			this->label4->Size = System::Drawing::Size(84, 13);
			this->label4->TabIndex = 5;
			this->label4->Text = L"Trigger Price:";
			// 
			// frmTrader
			// 
			this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
			this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
			this->ClientSize = System::Drawing::Size(273, 129);
			this->Controls->Add(this->tabControl1);
			this->Controls->Add(this->menuStrip1);
			this->Controls->Add(this->tws1);
			this->FormBorderStyle = System::Windows::Forms::FormBorderStyle::FixedSingle;
			this->MaximizeBox = false;
			this->Name = L"frmTrader";
			this->StartPosition = System::Windows::Forms::FormStartPosition::CenterScreen;
			this->Text = L"TradeIt";
			this->FormClosing += gcnew System::Windows::Forms::FormClosingEventHandler(this, &frmTrader::frmTrader_FormClosing);
			this->Load += gcnew System::EventHandler(this, &frmTrader::frmTrader_Load);
			(cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->tws1))->EndInit();
			this->tabControl1->ResumeLayout(false);
			this->tb1->ResumeLayout(false);
			this->tb1->PerformLayout();
			this->tb2->ResumeLayout(false);
			this->tb2->PerformLayout();
			this->menuStrip1->ResumeLayout(false);
			this->menuStrip1->PerformLayout();
			this->ResumeLayout(false);
			this->PerformLayout();

		}
#pragma endregion

	private:
		Account ^account;
		List<Symbol^> ^symbols;
		Symbol ^symForShow;

		MomentumWaveOptions ^mwOptions;

	private: System::Void frmTrader_Load(System::Object^  sender, System::EventArgs^  e)
			 {
				 account = gcnew Account(tws1);
				 symbols = gcnew List<Symbol^>;

				 mwOptions = gcnew MomentumWaveOptions();
				 mwOptions->SetToDefault();

				 tabControl1->SelectedIndex = 1;
			 }

	private: System::Void frmTrader_FormClosing(System::Object^  sender, System::Windows::Forms::FormClosingEventArgs^  e)
			 {
				 System::Windows::Forms::DialogResult result;

				 result = MessageBox::Show(this, "Are you sure you want to quit?", "Quit Program", MessageBoxButtons::YesNo);
				 if (result == ::DialogResult::No) { e->Cancel = true; return; }
				 exit(1);
			 }

	private: System::Void tws1_errMsg(System::Object^  sender, AxTWSLib::_DTwsEvents_errMsgEvent^  e)
			 {
				 if (e->errorMsg->Contains("999999")) return;
				 if (e->errorMsg->Contains("Order Canceled")) return;
				 if (e->errorMsg->Contains("Can't find order")) return;
				 if (e->errorMsg->Contains("Market data farm")) return;
				 if (e->errorMsg->Contains("HMDS data farm")) return;
				 if (e->errorMsg->Contains("Historical Market Data Service query")) return;

				 account->AddToLog("IB", e->errorMsg);
			 }

#pragma region Menu

	private: System::Void optionsToolStripMenuItem_Click(System::Object^  sender, System::EventArgs^  e)
			 {
				 frmOptions ^frmO;

				 frmO = gcnew frmOptions();
				 frmO->TopMost = this->TopMost;
				 frmO->ShowDialog();
			 }

	private: System::Void exitToolStripMenuItem_Click(System::Object^  sender, System::EventArgs^  e)
			 {
				 frmTrader_FormClosing(sender, gcnew FormClosingEventArgs(CloseReason::UserClosing, false));
			 }

	private: System::Void logToolStripMenuItem_Click(System::Object^  sender, System::EventArgs^  e)
			 {
				 frmLog ^frmL = gcnew frmLog(account);

				 frmL->TopMost = this->TopMost;
				 frmL->Show();
				 frmL->Top = this->Top + this->Height;
				 frmL->Left = this->Left;
			 }

	private: System::Void triggerExplorerToolStripMenuItem_Click(System::Object^  sender, System::EventArgs^  e)
			 {
				 frmPositionsInfo ^frmP = gcnew frmPositionsInfo(symbols);

				 frmP->TopMost = this->TopMost;
				 frmP->Show();
			 }

	private: System::Void doItToolStripMenuItem_Click(System::Object^  sender, System::EventArgs^  e)
			 {
				 int i;

				 for (i=0; i<symbols->Count; i++)
					 ((Symbol^)symbols[i])->Orders_()->CancelLimitsAndSellQuantity( ((Symbol^)symbols[i])->MarketData_()->Last() );
			 }

#pragma endregion

	private: System::Void btnBuy_S1_Click(System::Object^  sender, System::EventArgs^  e)
			 {

			 }

	private: System::Void btnSell_S1_Click(System::Object^  sender, System::EventArgs^  e)
			 {
				 
			 }

	private: System::Void btnBuy_S2_Click(System::Object^  sender, System::EventArgs^  e)
			 {
				 float delta = Convert::ToDouble(txtDelta_S2->Text);
				 int steps = Convert::ToInt16(txtSteps_S2->Text);
				 float triggerPrice = Convert::ToDouble(txtLast_S2->Text);
				 float stopLossPrice = Convert::ToDouble(txtStopLoss_S2->Text);
				 Side side = Long;

				 symbols->Add( gcnew Symbol(txtSymbol_S2->Text, account) );
				 ((Symbol^)symbols[symbols->Count-1])->Strategy_()->Add( gcnew MomentumWave(symbols[symbols->Count-1], mwOptions->Clone(), delta, steps, triggerPrice, stopLossPrice, side) );
			 }

	private: System::Void btnSell_S2_Click(System::Object^  sender, System::EventArgs^  e)
			 {

			 }

#pragma region MOMENTUM WAVE

	private: bool Strategy2_CheckForInput()
			 {
				 //if (txtSymbol_S1->Text == "" || !Information::IsNumeric(txtTrigger_S1->Text) || !Information::IsNumeric(txtStop_S1->Text) || !Information::IsNumeric(txtSize_S1->Text) || txtSize_S1->BackColor != Color::White)
				 //{
				 // MessageBox::Show("Momentum Breaker - Please check all fields again");
				 // return false;
				 //}

				 return true;
			 }

	private: System::Void txtSymbol_S2_TextChanged(System::Object^  sender, System::EventArgs^  e)
			 {
				 txtSymbol_S2->Text = txtSymbol_S2->Text->ToUpper();
				 txtSymbol_S2->SelectionStart = 100;
			 }

	private: System::Void txtSymbol_S2_LostFocus(System::Object^  sender, System::EventArgs^  e)
			 {
				 if (txtSymbol_S2->Text == "") return;

				 if (txtDelta_S2->Text == "")
				 {
					 txtDelta_S2->Text = "0.";
					 txtDelta_S2->SelectionStart = 10;
					 symForShow = gcnew Symbol(txtSymbol_S2->Text, account);
					 symForShow->MarketData_()->Start(txtLast_S2);
					 txtStopLoss_S2->Text = "...";
				 }

				 txtSymbol_S2->Text = txtSymbol_S2->Text->ToUpper();
			 }

	private: System::Void txtSymbol_S2_GotFocus(System::Object^  sender, System::EventArgs^  e)
			 {
				 txtSymbol_S2->Text = "";
				 txtDelta_S2->Text = "";
				 txtSteps_S2->Text = "";
				 txtStopLoss_S2->Text = "";
				 txtLast_S2->Text = "";
			 }

	private: System::Void txtDelta_S2_KeyUp(System::Object^  sender, System::Windows::Forms::KeyEventArgs^  e)
			 {
				 if (!Information::IsNumeric(txtDelta_S2->Text)) return;

				 if (e->KeyCode == Keys::Up && e->Shift == false)
					 txtDelta_S2->Text = Convert::ToString(Convert::ToDouble(txtDelta_S2->Text) + 0.01);
				 if (e->KeyCode == Keys::Down && e->Shift == false)
					 txtDelta_S2->Text = Convert::ToString(Convert::ToDouble(txtDelta_S2->Text) - 0.01);
				 if (e->KeyCode == Keys::Up && e->Shift == true)
					 txtDelta_S2->Text = Convert::ToString(Convert::ToDouble(txtDelta_S2->Text) + 0.05);
				 if (e->KeyCode == Keys::Down && e->Shift == true)
					 txtDelta_S2->Text = Convert::ToString(Convert::ToDouble(txtDelta_S2->Text) - 0.05);
				 if (Convert::ToDouble(txtDelta_S2->Text) < 0) txtDelta_S2->Text = "0";

				 txtDelta_S2->SelectionStart = 10;
				 txtSteps_S2->Text = Convert::ToString( CalculateSteps_S2() );
				 if ( Information::IsNumeric(txtLast_S2->Text) ) txtStopLoss_S2->Text = Convert::ToString( Convert::ToDouble(txtLast_S2->Text) - CalculateSteps_S2() * Convert::ToDouble(txtDelta_S2->Text) );
			 }

	private: int CalculateSteps_S2()
			 {
				 if ( !Information::IsNumeric(txtDelta_S2->Text) ) return 0;
				 if ( Convert::ToDouble(txtDelta_S2->Text) == 0 ) return 0;

				 int step = mwOptions->firstQuantity * Convert::ToDouble(txtDelta_S2->Text);
				 int counter = 0;

				 while (step <= mwOptions->riskInDollar)
				 {
					 step = step + (mwOptions->firstQuantity * Convert::ToDouble(txtDelta_S2->Text)) + mwOptions->quantityToAdd * Convert::ToDouble(txtDelta_S2->Text);
					 counter++;
				 }

				 return counter;
			 }

	private: System::Void txtLast_S2_TextChanged(System::Object^  sender, System::EventArgs^  e)
			 {
				 if ( Information::IsNumeric(txtLast_S2->Text) )
				 {
					 txtStopLoss_S2->Text = "0";
					 txtSteps_S2->Text = Convert::ToString( CalculateSteps_S2() );
					 if ( Information::IsNumeric(txtLast_S2->Text) ) txtStopLoss_S2->Text = Convert::ToString( Convert::ToDouble(txtLast_S2->Text) - CalculateSteps_S2() * Convert::ToDouble(txtDelta_S2->Text) );
				 }
			 }

#pragma endregion


};
}
